package org.langcom.logic;

public abstract class LogicOperation extends AbstractCompositeLogic {

	private static final long serialVersionUID = -3037589318399539407L;

	protected LogicOperation(String description, String detailedDescription) {
		super(description, detailedDescription);
	}

	public boolean tryOn() throws Exception {
		if (children.isEmpty()) {
			throw new IllegalStateException();
		}
		boolean result = children.get(0).check();
		for (int i = 1; i < children.size(); i++) {
			result = compare(result, children.get(i).check());
		}
		return result;
	}

	protected abstract boolean compare(boolean arg1, boolean arg2);
}
